<?php
$ids = $this->getRequest()->getPost('creditmemo_ids');

$_coreHelper = $this->helper('core');
$collection = Mage::getModel('sales/order_creditmemo')->getCollection()
	->addFieldToSelect('*')
	->addFieldToFilter('entity_id', array('in'=>$ids));

?>
<div class="print">
		<?php foreach($collection as $memo):?>
			<div class="order-print">
			<div class="head" style="text-align:center;font-weight:bold;font-size:20pt;" align="center"><center>退款单</center></div>
			<?php $order = Mage::getModel("sales/order")->load($memo->getOrderId());?>
			<?php $createdAt = strtotime($memo->getCreatedAt()); ?>
			<div class="head" style="clear:both"><div class="fl">退款单编号：#<?php echo $memo->getIncrementId();?>&nbsp;&nbsp;订单编号：#<?php echo $order->getIncrementId();?></div> <div class="fr">退款日期：<?php echo date("Y年m月d日 H:i", $createdAt+3600*8);?> <a href="javascript:window.print();" class="actions"> 打印</a></div></div>
			<?php $items = $memo->getItemsCollection();?>
			<table class="data-table">
				<tr>
					<td>商品名</td>
					<td width="8%">SKU</td>
					<td width="12%">退货数量</td>
					<td width="8%">单价</td>
					<td width="13%">小计</td>
				</tr>
				<?php foreach($items as $item):?>
				<tr>
					<td><?php echo $item->getName(); ?></td>
					<td><?php echo $item->getSku(); ?></td>
					<td><?php echo intval($item->getQty()); ?></td>
					<td><?php echo $_coreHelper->formatPrice($item->getPrice()); ?></td>
					<td><?php echo $_coreHelper->formatPrice($item->getRowTotal()); ?></td>
				</tr>
				<?php endforeach;?>
				<?php if($memo->getGrandTotal() != $memo->getSubtotal()):?>
				<tr>
					<td colspan="4" align="right" style="text-align:right" align="right"><span style="text-align:right">合计</span></td>
					<td><?php echo $_coreHelper->formatPrice($memo->getSubtotal(),false); ?></td>
				</tr>
				<?php endif;?>
				<tr>
					<td colspan="4" align="right" style="text-align:right" align="right"><span style="text-align:right">总计</span></td>
					<td><?php echo $_coreHelper->formatPrice($memo->getGrandTotal(),false); ?></td>
				</tr>
			</table>
			<div class="address">
			<?php $customer = Mage::getModel('customer/customer')->load($order->getCustomerId()); ?>
			配送地址：<?php echo $order->getShippingAddress()->format("oneline")." （".$customer->getLastname()."）";?>
			<?php
			$store = Mage::helper('qslb')->getStore($customer->getId());
			if($store && isset($store['addressDescription']) && $store['addressDescription'])
			{
				echo "</br>备注：{$store['addressDescription']}";
			}
			?>
		</div>
		<div class="signature" style="clear:both">
				<div class="item"><span class="label">送货人：</span><span class="placeholder">&nbsp;</span></div>
				<div class="item"><span class="label">财务：</span><span class="placeholder">&nbsp;</span></div>
				<div class="item"><span class="label">仓库：</span><span class="placeholder">&nbsp;</span></div>
			</div>
		</div>
		<?php endforeach;?>
</div>